package cn.iocoder.boot.demokeycloakbk.rsa;

import java.security.KeyPair;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;

public class JwtDemo {

    public static void main(String[] args) {
        try {
            // 生成密钥对
            KeyPair keyPair = RsaKeyPairGenerator.generateKeyPair();

            // 使用私钥签名JWT
            String token = JwtSigner.signJwt((RSAPrivateKey) keyPair.getPrivate());
            System.out.println("Signed JWT: " + token);

            // 使用公钥验证签名
            JwtVerifier.verifyJwt(token, (RSAPublicKey) keyPair.getPublic());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
